***********************
*Time Series Analysis for the Social Sciences
*Box-Steffensmeier, Freeman, Hitt, and Pevehouse
*
*Chapter 6 replication code
************************

************************
*Figures 6.1-6.5, Tables 6.1-6.3
*Use pop_gdp.dta
************************

*Table 6.1

reg pop pcGDP
predict olsresid, resid

*Figure 6.1

ac olsresid
pac olsresid

*Figure 6.2

ac pop
pac pop


*Table 6.2

arima pop, arima(1,1,0)

predict arima110resid, resid

*Figure 6.3

ac pcGDP
pac pcGDP


*Figure 6.4

ac D.pop
pac D.pop

graph combine acf_dpop.gph pacf_dpop.gph, cols(2) 

*Table 6.3

reg arima110res D.pcGDP
predict filterres, resid

*Figure 6.5

ac filterres
pac filterres

***********************
*Figure 6.6, Tables 6.5-6.7 
*Use indipaki.dta
***********************

tsset year

*Figure 6.6

tsline pakds if year < 1991 || tsline indds if year < 1991

*Table 6.5
	*l.res2 is our cointegrating vector from the residuals of regressing indds on pakds

varsoc d.indds d.pakds if year < 1991, exog(l.res2) lut

*Table 6.6

	*India
	
reg D.indds l.res2 if year < 1991

	*Pakistan
	
reg D.pakds l.res2 if year < 1991

*Table 6.7

var d.indds d.pakds if year<=1990, exog(l.res2) lags(1/3)
vargranger
